<!DOCTYPE html>
<html>
<head>
    {include file="../application/common/header.html" /}
</head>

<body>
    <div id="student_managetb">
        <form id="student_manageForm" class="m5">
            <?php echo currTerm()["termName"]?>
            <select class="form-control1" name="grade" id="grade" onchange="getClazz('student_manage',this.value)"></select>
            <select class="form-control1" name="clazz" id="clazz"></select>
            学生姓名：
            <input class="form-control1" type="text" name="studentName" id="studentName">
            <a class="easyui-linkbutton l-btn l-btn-small" data-options="iconCls:'icon-search'" onclick="searchForm('student_manage')">查询</a>
            <a class="easyui-linkbutton l-btn l-btn-small" data-options="iconCls:'icon-clear'" onclick="resetForm('student_manage')">重置</a><br/>
        </form>
    </div>
    <table id="student_managedg">
        <thead frozen="true">
            <tr>
                <th data-options="field:'ID',checkbox:true">ID</th>
                <th data-options="field:'年级号',title:'年级名称',formatter:function(value,row,index){
                    return row.gradeName;
                }"></th>
                <th data-options="field:'班号',title:'班号'"></th>
                <th data-options="field:'学号',title:'学号'"></th>
                <th data-options="field:'姓名',title:'姓名'"></th>
            </tr>
        </thead>
        <thead>
            <tr>
                <th data-options="field:'性别',title:'性别'"></th>
                <th data-options="field:'身份证类型',title:'身份证类型'"></th>
                <th data-options="field:'身份证号',title:'身份证号'"></th>
                <th data-options="field:'生日',title:'生日'"></th>

                <th data-options="field:'民族',title:'民族'"></th>
                <th data-options="field:'国籍',title:'国籍'"></th>
                <th data-options="field:'户口性质',title:'户口性质'"></th>
                <th data-options="field:'户籍类别',title:'户籍类别'"></th>
                <th data-options="field:'户籍省市区',title:'户籍省市区'"></th>
                <th data-options="field:'户籍所在详细地址',title:'户籍所在详细地址'"></th>
                <th data-options="field:'现住地址',title:'现住地址'"></th>
                <th data-options="field:'是否独生子女',title:'是否独生子女'"></th>
                <th data-options="field:'户籍类别',title:'户籍类别'"></th>
                <th data-options="field:'籍贯',title:'籍贯'"></th>
                <th data-options="field:'生源地',title:'生源地'"></th>
                <th data-options="field:'父亲姓名',title:'爸爸姓名'"></th>
                <th data-options="field:'父亲电话',title:'爸爸电话'"></th>
                <th data-options="field:'爸爸是否监护人',title:'爸爸是否监护人'"></th>
                <th data-options="field:'爸爸户口所在地',title:'爸爸户口所在地'"></th>
                <th data-options="field:'爸爸现住址',title:'爸爸现住址'"></th>
                <th data-options="field:'母亲姓名',title:'妈妈姓名'"></th>
                <th data-options="field:'母亲电话',title:'妈妈电话'"></th>
                <th data-options="field:'妈妈是否监护人',title:'妈妈是否监护人'"></th>
                <th data-options="field:'妈妈户口所在地',title:'妈妈户口所在地'"></th>
                <th data-options="field:'妈妈现住址',title:'妈妈现住址'"></th>
            </tr>
        </thead>
    </table>
    <div id="uploadBox" style="display: none;height: auto;">
        <div class="m30">
            <form method="post" enctype="multipart/form-data" id="student_manageUploadForm" action="">
                <div class="mt20">
                    <input class="easyui-filebox" data-options="buttonText:'选择文件'" id="files" name="files" style="width:250px;">
                </div>
            </form>
        </div>
        <div class="tnc m20">
            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="uploadCommit('student_manage')" style="width: 200px;">上传</a>
        </div>
    </div>
    <script type="text/javascript">
        var url = "/student/student_manage";
        $(function(){
            initDatagrid('student_manage', url);
            initGrade("student_manage");
        })
        function initDatagrid(cf, url) {
            var btnArr=[];
            btnArr.push({text:'增加',iconCls:'icon-add',handler:function(){
                    window.top["student_manage"]=function(){
                        dgObj.datagrid("reload");
                    };
                    addTab('新增学生','studentUpdate/0');
            }},'-');
            btnArr.push({text:'删除',iconCls:'icon-remove',handler:function(){del(cf, url)}},'-');
            btnArr.push({text:'修改',iconCls:'icon-edit',handler:function(){
                    var dgObj=$('#student_managedg');
                    var rows=dgObj.datagrid('getSelections');
                    if(rows.length == 0) return;
                    window.top["student_manage"]=function(){
                        dgObj.datagrid("reload");
                    };
                    var url = "studentUpdate/" + rows[0].ID;
                    addTab('修改学生信息', url);
            }},'-');
            btnArr.push({text:'导出为EXCEL',iconCls:'icon-save',handler:function(){outExcel(cf,url)}},"-");
            btnArr.push({text:'下载EXCEL模板',iconCls:'icon-tip',handler:function(){downloadTemplate('学生信息花名册模板.xls')}},"-");
            btnArr.push({text:'导入',iconCls:'icon-large-smartart',handler:function(){importExcel('student_manage')}},"-");
            $("#student_managedg").datagrid({
                url: url + "/pageQuery.html",
                rownumbers: true,
                striped: true,
                border: false,
                pagination: true,
                pageSize: 30,
                fitColumns: true,
                autoRowHeight: false,
                singleSelect: true,
                fit: true,
                toolbar: btnArr
            })
            var tb = $("#"+cf+"tb").html();
            if(tb) {
                $(".datagrid-toolbar").prepend(tb);
                $("#"+cf+"tb").remove();
            }
        }
        function downloadTemplate(name){
            window.location.href = "__STATIC__/template/" + name;
        }
        function importExcel(cf) {
            $('#uploadBox').dialog({
                title : '学生信息导入',
                modal : true,
                width : 400,
                top : 100,
                buttons : '#btns'
            }).show();
        }
        function uploadCommit(cf){
            $('#student_manageUploadForm').form('submit',{
                url: url + "/importExcel.html",
                success:function(data){
                $.messager.progress('close');
                if(data == '000') {
                    $.messager.show({title:'操作提示', msg:"上传成功"});
                    $('#uploadBox').dialog("close");
                    searchForm('student_manage');
                    return;
                }
                $.messager.alert('提示', data);
            }})
        }
    </script>
</body>
</html>